﻿<Window x:Class="WebViewerTest.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:local="clr-namespace:WebViewerTest"
    Title="YouCube" Background="Black">

	<Window.Resources>
	</Window.Resources>

	<Grid>

		<Grid.RowDefinitions>
			<RowDefinition Height="Auto"/>
			<RowDefinition/>
		</Grid.RowDefinitions>

		<Grid Name="mainContent" Focusable="true" Grid.Row="0" Grid.RowSpan="2" Background="Transparent">

			<Viewport3D Name="viewport">
				<Viewport2DVisual3D>
					<Viewport2DVisual3D.Geometry>

						<!-- Cube positions from Charles Petzold's blog - http://www.charlespetzold.com/ -->
						<!-- Unit cube: front, back, left, 
													right, top, bottom. -->
						<MeshGeometry3D
										Positions="-0.5  0.5  0.5,  0.5  0.5  0.5,
												   -0.5 -0.5  0.5,  0.5 -0.5  0.5,

													0.5  0.5 -0.5, -0.5  0.5 -0.5,
													0.5 -0.5 -0.5, -0.5 -0.5 -0.5,

												   -0.5  0.5 -0.5, -0.5  0.5  0.5,
												   -0.5 -0.5 -0.5, -0.5 -0.5  0.5,
	        
													0.5  0.5  0.5,  0.5  0.5 -0.5,
													0.5 -0.5  0.5,  0.5 -0.5 -0.5,

												   -0.5  0.5 -0.5,  0.5  0.5 -0.5,
												   -0.5  0.5  0.5,  0.5  0.5  0.5,
	        
													0.5 -0.5 -0.5, -0.5 -0.5 -0.5,
													0.5 -0.5  0.5, -0.5 -0.5  0.5"

										TriangleIndices=" 0  2  1,  1  2  3
														  4  6  5,  5  6  7,
														  8 10  9,  9 10 11,
														 12 14 13, 13 14 15
														 16 18 17, 17 18 19
														 20 22 21, 21 22 23"

										TextureCoordinates="0 0, 1 0, 0 1, 1 1,
															0 0, 1 0, 0 1, 1 1,
															0 0, 1 0, 0 1, 1 1,
															0 0, 1 0, 0 1, 1 1,
															0 0, 1 0, 0 1, 1 1,
															0 0, 1 0, 0 1, 1 1" />
					</Viewport2DVisual3D.Geometry>

					<Viewport2DVisual3D.Material>
						<MaterialGroup>
							<DiffuseMaterial Brush="White" Viewport2DVisual3D.IsVisualHostMaterial="True"/>
							<SpecularMaterial SpecularPower="100" Brush="White"/>
						</MaterialGroup>
					</Viewport2DVisual3D.Material>

					<local:CjcWebBrowser x:Name="browserProxy1"
										 Owner="{Binding ElementName=mainContent}"
										 Width="1024" Height="1024"/>

				</Viewport2DVisual3D>

				<ModelVisual3D>
					<ModelVisual3D.Content>
						<Model3DGroup>
							<!-- Light source. -->
							<AmbientLight Color="#505050" />
							<DirectionalLight x:Name="light" Color="#808080" Direction="0,0,-1"/>
						</Model3DGroup>
					</ModelVisual3D.Content>
				</ModelVisual3D>

				<!-- Camera. -->
				<Viewport3D.Camera>
					<PerspectiveCamera x:Name="camera"
									   Position="0 0 2"
									   LookDirection="0 0 -2"
									   UpDirection="0 1 0"
									   FieldOfView="60"
									   NearPlaneDistance="0" />
				</Viewport3D.Camera>

			</Viewport3D>

		</Grid>

		<Border Grid.Row="0" Padding="10" Background="#30000000" CornerRadius="10" Opacity="0.5">
			<Border.Resources>
				<Storyboard x:Key="fadeIn">
					<DoubleAnimation Storyboard.TargetProperty="Opacity" To="1.0" Duration="0:0:0.25"/>
				</Storyboard>
				<Storyboard x:Key="fadeOut">
					<DoubleAnimation Storyboard.TargetProperty="Opacity" To="0.5" Duration="0:0:0.5"/>
				</Storyboard>
			</Border.Resources>
			<Border.Triggers>
				<EventTrigger RoutedEvent="UIElement.MouseEnter">
					<BeginStoryboard Storyboard="{StaticResource fadeIn}"/>
				</EventTrigger>
				<EventTrigger RoutedEvent="UIElement.MouseLeave">
					<BeginStoryboard Storyboard="{StaticResource fadeOut}"/>
				</EventTrigger>
			</Border.Triggers>
			<Grid>
				<Grid.ColumnDefinitions>
					<ColumnDefinition Width="Auto"/>
					<ColumnDefinition/>
					<ColumnDefinition Width="Auto"/>
				</Grid.ColumnDefinitions>
				<Label Grid.Column="0" Foreground="White">Address</Label>
				<Grid Grid.Column="1">
					<Rectangle>
						<Rectangle.Fill>
							<DrawingBrush>
								<DrawingBrush.Drawing>
									<DrawingGroup>
										<GeometryDrawing Brush="White">
											<GeometryDrawing.Geometry>
												<RectangleGeometry Rect="0,0,1,1"/>
											</GeometryDrawing.Geometry>
										</GeometryDrawing>
										<GeometryDrawing>
											<GeometryDrawing.Brush>
												<LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
													<GradientStop Offset="0" Color="#80FF80"/>
													<GradientStop Offset="0.3" Color="#E0FFE0"/>
													<GradientStop Offset="1" Color="#80FF80"/>
												</LinearGradientBrush>
											</GeometryDrawing.Brush>
											<GeometryDrawing.Geometry>
												<RectangleGeometry Rect="{Binding ElementName=browser1, Path=ProgressRect}"/>
											</GeometryDrawing.Geometry>
										</GeometryDrawing>
									</DrawingGroup>
								</DrawingBrush.Drawing>
							</DrawingBrush>
						</Rectangle.Fill>
					</Rectangle>
					<TextBox Name="url" Text="http://chriscavanagh.wordpress.com" TextChanged="url_TextChanged" Background="Transparent"/>
				</Grid>
				<Button Grid.Column="2" Margin="5,0,0,0" Click="Button_Click" IsDefault="True">Go</Button>
			</Grid>
		</Border>

	</Grid>
</Window>
